package framework.utils;

import java.util.*;

/**
 * Class for storing all Global data needed in our framework
 * @class UserPreferences
 * @author Michel
 * @version 1.0
 */
public final class UserPreferences {

	//Properties map
	public static final HashMap<String,Object> properties = new HashMap<String,Object>();

	/**
	 * Class which cannot be instantiated
	 * @method UserPreferences (Constructor)
	 */
	private UserPreferences() {
		//INFO -> Do not instantiate
	};
	
	/**
	 * @method getProperty
	 * @param <String> key
	 * @return <Object> value
	 */
	public static Object getProperty(String key) {
		return UserPreferences.properties.get(key);
	};
	
	/**
	 * @method getProperty
	 * @param <String> key
	 * @param <Object> defaultValue
	 * @return <Object> value
	 */
	public static Object getProperty(String key, Object defaultValue) {
		//Get propery value by key
		Object value = UserPreferences.properties.get(key);
		//Return property value if found by key else defaultValue
		return value != null ? value : defaultValue;
	};

	/**
	 * @method setProperty
	 * @param <String> key
	 * @param <Object> value
	 */
	public static void setProperty(String key, Object value) {
		UserPreferences.properties.put(key, value);
	};
	
}
